from pom.BasePage import BasePage
from selenium.webdriver.common.by import By
import time


# 订单管理模块
class OrderPage(BasePage):
    # 元素定位
    orderM = (By.XPATH, '//*[@id="collapse-nav-business"]/li[1]/a')  # 订单管理
    qx = (By.XPATH, '//div[@class="form-table-content"]//span[text()=\'取消\']')  # 取消按钮
    delt = (By.XPATH, '//div[@class="form-table-content"]//span[text()=\'删除\']')  # 删除按钮
    pay = (By.XPATH, '//div[@class="form-table-content"]//span[text()=\'支付\']')  # 支付按钮
    qd = (By.XPATH, '//div[@class="am-modal-dialog"]//span[@data-am-modal-confirm]')  # 弹窗确认按钮
    qdpay = (By.XPATH, '//div[@id="order-pay-popup"]//button[@type="submit"]')  # 定位确认支付按钮
    morder = (By.XPATH, '//div[@class="tips-nav"]//a[text()=\'我的订单\']')  # 定位我的订单按钮

    # 订单取消
    def order_qx(self):
        self.click(self.orderM)
        self.click(self.qx)
        time.sleep(2)
        self.click(self.qd)

    # 订单删除
    def order_del(self):
        self.click(self.orderM)
        self.click(self.delt)
        time.sleep(2)
        self.click(self.qd)

    # 订单支付
    def order_pay(self):
        self.click(self.orderM)
        self.click(self.pay)
        time.sleep(2)
        self.click(self.qdpay)
        time.sleep(1)
        self.click(self.morder)
